<?
ignore_user_abort(false);

require("config/config.php");
require("lib/lib.mysql.php");
require("lib/lib.common.php");
require("lib/lib.htdb.php");

$db = new db;
$db->connect($db_host, $db_user, $db_pass, $db_name);
$common = new common;
$session = new session($common,$db);

if(!$session->logged_in ||
($common->confirm_uid($_SESSION["uid"],$db)!=0))
   $common->redirect("cms_login.php");

	$username = $_REQUEST["username"];
	$password = $_REQUEST["password"];
	$fname = $_REQUEST["fname"];
	$lname = $_REQUEST["lname"];
	$email = $_REQUEST["email"];
	$active_ind = $_REQUEST["active_ind"];

$htdb = new htdb;

$action = $_GET["action"];

switch ($action) {
case "add":

	$member_id = $htdb->add_member($username,$password,$fname,$lname,$email,$db);

   break;
case "edit":
	$member_id = $_REQUEST["member_id"];
	$update = $htdb->update_member($member_id,$fname,$lname,$email,$active_ind, $db);

   break;
}

$member = $htdb->view_member($member_id, $db);

ob_start();
require("templates/cms_edit_member.htm");
$output = ob_get_contents();
ob_end_clean();

print $output;

$db->close();
?>